/*
** time_execution.c for  in /home/massro_a//zappy-2011/new_server/src
** 
** Made by ancet massrouf
** Login   <massro_a@epitech.net>
** 
** Started on  Mon Jul  4 18:48:05 2011 ancet massrouf
** Last update Sun Jul 10 22:59:24 2011 el-hadji-malick-ndour dieng
*/
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include "team.h"
#include "types.h"
t_option        which_option[14]=
  {
    {"avance", cmd_avance},
    {"droite", cmd_droite},
    {"gauche", cmd_gauche},
    {"voir", cmd_voir},
    {"inventaire", cmd_inventaire},
    {"prend objet", cmd_prend_obj},
    {"pose objet", cmd_pose_obj},
    {"expulse", cmd_expulse},
    {"broadcast texte", cmd_broadcast_text},
    {"incantation", cmd_incantation},
    {"fork", cmd_fork},
    {"connect_nbr", cmd_connect_nbr},
    {"_", cmd__},
    {0, 0}
  };

t_good_request	*request_parser(char * cmd, int t)
{
  t_good_request	*request;
  int           i;

  request = malloc(sizeof(*request));
  i = 0;
  if (*cmd == '\0')
    return (NULL);
  while (which_option[i].option != 0)
    {
      if (strcmp(cmd, which_option[i].option) == 0)
        {
	  request->name = strdup(cmd);
	  request->duration = which_option[i].duration(cmd, t);
	  request->time = current_time();
	  return (request);
	}
      else
        i++;
    }
  printf("%d: Sending KO to client", current_time());
  return (NULL);
}
